Skip to content

Conversation

@adityasasidhar
Copy link

Hey everyone! This is my very first contribution to Memori. I've added some unit tests for the _cli.py module to make sure our command line output, like the banner and notices, always looks and behaves exactly as expected.

@devwdave
Copy link
Collaborator

Hi @adityasasidhar

Thanks for putting this together. I appreciate you taking the time to add coverage around the CLI helpers.

One concern on my end is that these tests are primarily asserting exact print() output. In practice that tends to be a bit brittle (small copy/format tweaks can break CI) and it doesn’t really exercise the failure modes we'd be concerned with in the cli; argument parsing, command wiring, exit codes, and error paths.

Would you be open to adjusting the tests toward higher signal behavior? For example, invoking the CLI/entrypoint in a more end-to-end way (args → command execution) and asserting on exit codes and a couple key outcomes, while keeping output checks looser (e.g., version is present, important keywords show up) rather than matching exact strings.

@adityasasidhar
Copy link
Author

Hey @devwdave,

Thanks for the thoughtful feedback. You’re absolutely right. I agree that asserting exact print() output is brittle and low-signal.

I’m happy to move forward with your suggestion and refactor the tests toward higher-level CLI behavior by invoking the entrypoint with arguments, asserting on exit codes, command wiring, and error paths, while keeping output checks loose (presence of key markers rather than exact matches).

I’ll push an updated commit reflecting this shortly.

adityasasidhar added a commit to adityasasidhar/Memori that referenced this pull request Jan 21, 2026
Add comprehensive end-to-end CLI tests

- Added 16 comprehensive CLI tests covering help variations, command validation, and error handling
- Implemented tests for CockroachDB cluster management commands (start, claim, delete)
- Added ASCII logo display verification test
- Used parametrized tests for multiple help invocation methods (no args, --help, -h, help)
- Refactored tests to use behavior-based assertions instead of exact string matching
- Improved test assertions to validate both exit codes and error messages
- Updated CHANGELOG.md with test improvements

Addresses reviewer feedback on PR MemoriLabs#249 to make tests less brittle and more behavior-focused.
- Added 16 comprehensive CLI tests covering help variations, command validation, and error handling
- Implemented tests for CockroachDB cluster management commands (start, claim, delete)
- Added ASCII logo display verification test
- Used parametrized tests for multiple help invocation methods (no args, --help, -h, help)
- Refactored tests to use behavior-based assertions instead of exact string matching
- Improved test assertions to validate both exit codes and error messages
- Updated CHANGELOG.md with test improvements

Addresses reviewer feedback on PR MemoriLabs#249 to make tests less brittle and more behavior-focused.
@adityasasidhar
Copy link
Author

Hi @devwdave,

Thanks for the detailed feedback. I’ve refactored the tests based on your suggestions. Below is a quick summary of what I changed.

What Changed

End-to-End Testing

  • Switched from unit tests to subprocess-based E2E tests
  • Tests now invoke python -m memori, matching how a real user runs the CLI
  • This exercises the full CLI entrypoint instead of isolated helpers

More Behavior-Focused Assertions

  • Earlier tests relied on exact string matching, for example:
    • assert captured.out == "+ Hello World\n"
  • Updated tests now check for key signals instead:
    • assert "usage" in result.stdout.lower()
  • Assertions focus on exit codes and expected behavior rather than formatting

Expanded Coverage

Added 16 tests covering:

  • Help behavior with no args, --help, -h, and help using parametrization
  • Invalid command handling
  • CockroachDB cluster commands (start, claim, delete)
  • Missing argument validation, such as sign-up without an email
  • ASCII logo output
  • Exit code checks (0 for success, 1 for failure cases)

Test Quality Improvements

  • Assertions now validate both exit codes and relevant output
  • Parametrized tests reduce repetition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants